package com.usian.admin.controller;

import com.usian.admin.service.AdSensitiveService;
import com.usian.apis.admin.AdSensitiveControllerApi;
import com.usian.model.admin.dtos.SensitiveDto;
import com.usian.model.admin.pojos.AdSensitive;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@CrossOrigin
@RestController
@RequestMapping("/admin/api/v1/sensitive")
public class AdSensitiveController implements AdSensitiveControllerApi {

    @Autowired
    private AdSensitiveService adSensitiveService;


    @PostMapping("/list")
    @Override
    public ResponseResult findByNameAndPage(@RequestBody SensitiveDto sensitiveDto) {
        return adSensitiveService.findNameByPage (sensitiveDto);
    }

    @PostMapping("/save")
    @Override
    public ResponseResult save(@RequestBody AdSensitive adSensitive) {
        adSensitiveService.save1 (adSensitive);
        return (ResponseResult.okResult (7777, "添加成功"));
    }

    @PostMapping("/update")
    @Override
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        adSensitiveService.updateById (adSensitive);
        return (ResponseResult.okResult (8888, "修改成功"));
    }

    @DeleteMapping  ("/del/{id}")
    @Override
    public ResponseResult del(@PathVariable Integer id) {
        adSensitiveService.removeById (id);
        return (ResponseResult.okResult (500, "删除成功"));
    }

    @PostMapping("/deletes")
    @Override
    public ResponseResult deletes(@RequestBody Integer[] ids) {
        return adSensitiveService.deletes(ids);
    }

}
